function initMenu() {
  $('#leftnav ul').hide();
  $('#leftnav li a').click(
    function() {
        $(this).next().slideToggle('normal');	
      }
    );
  }

function showSlidingDiv(){
$("#slidingDiv").animate({"height": "toggle"}, { duration: 1000 });
}
 
$("document").ready(function() {

initMenu();
showSlidingDiv();	
	$("div.item-wrap") 
	.before('<div class="featured-nav">') 
	.cycle({ 
	    fx:     'fade',  
	    timeout: 4000, 
	    pager:  '.featured-nav',
	    cleartype: true, 
	    cleartypeNoBg: true
	});

	
	$(function() {
		var contentWrapper = $('.main > .tab');
		contentWrapper.hide().filter(':first').show();
		
		$('.main ul.tabs-nav li a').click(function () {
		
		    if (this.className.indexOf('current') == -1){
		    	contentWrapper.hide();
		    	contentWrapper.filter(this.hash).fadeIn(500);
		    	$('.main ul.tabs-nav li a').removeClass('current');
		    	$(this).addClass('current');
		    }
		    return false;
		});
	});

	
	$("ul.gallery li:nth-child(3n+0), ul.posts li:nth-child(2n+0), ul.portfolio li:nth-child(3n+0)").css("margin-right", "0");
	$("ul.categories li:nth-child(2n+0)").css("margin-left", "30px");
	
});


function imageLoader() {
	
    $('.loader').each(function () {
					  
        var loader = $(this);
        var pathToImage = loader.attr('title');
        var img = new Image();
	  
        $(img).css("opacity", "0.0").load(function () {
								    
            loader.append(this).removeAttr('title');
		
            $(this).css("margin", "0px").css("opacity", "0.0").animate({
											     
                opacity: 1.0
		    
            },400, function () {
			
                loader.css({ "background-image": "none", "background-color": "transparent" });
		    
            });
		
        }).attr('src', pathToImage);
	  
    });
    
}

$("document").ready(function() {
    imageLoader();
});


